package com.mes.cloud.web;

import com.mes.cloud.api.dto.request.product.ProductIdentifyProductsAddRequest;
import com.mes.cloud.api.dto.request.product.ProductIdentifyProductsEnableRequest;
import com.mes.cloud.api.dto.request.product.ProductIdentifyProductsPageRequest;
import com.mes.cloud.api.dto.response.product.ProductIdentifyProductsPageDto;
import com.mes.cloud.common.CommPager;
import com.mes.cloud.common.JsonResult;
import com.mes.cloud.service.ProductIdentifyProductsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author xy
 * @version 2019-08-23 10:37:15
 * @email yuan.xue3@pactera.com
 */
@Api(tags = "标识产品", value = "标识产品接口")
@RestController
@RequestMapping(value = "/productIdentifyProducts")
public class ProductIdentifyProductsController  {

    private ProductIdentifyProductsService productIdentifyProductsService;

    @Autowired
    public ProductIdentifyProductsController(ProductIdentifyProductsService productIdentifyProductsService) {
        this.productIdentifyProductsService = productIdentifyProductsService;
    }

    /**
     * 功能: 标识产品关联分页查询
     *
     * @param pageRequest
     * @return JsonResult<CommPager<ProductIdentifyProductsDto>>
     */
    @ApiOperation(value = "标识产品关联分页查询", notes = "标识产品关联分页查询")
    @PostMapping(value = "/pageList")
    public JsonResult<CommPager<ProductIdentifyProductsPageDto>> pageList(@Valid @RequestBody ProductIdentifyProductsPageRequest pageRequest) {
        return productIdentifyProductsService.pageList(pageRequest);
    }


    /**
     * 功能: 标识产品关联新增
     *
     * @param productIdentifyProductsRequest
     * @return JsonResult
     */
    @ApiOperation(value = "新增标识产品关联", notes = "新增标识产品关联")
    @PostMapping(value = "/add")
    public JsonResult add(@Valid @RequestBody ProductIdentifyProductsAddRequest productIdentifyProductsRequest) {
        return productIdentifyProductsService.add(productIdentifyProductsRequest);
    }

    /**
     * 功能: 标识产品移除关联
     *
     * @param productIdentifyProductsEnableRequest
     * @return JsonResult
     */
    @ApiOperation(value = "标识产品移除关联", notes = "标识产品移除关联")
    @PostMapping(value = "/updateEnableFlag")
    public JsonResult updateEnableFlag(@Valid @RequestBody ProductIdentifyProductsEnableRequest productIdentifyProductsEnableRequest) {
        return productIdentifyProductsService.updateEnableFlag(productIdentifyProductsEnableRequest);
    }
}
